
const app = getApp();
const ipconfig = app.globalData.ipconfig;
var http = require('../../../utils/http')
Page({

   
    data: {
        feedback:{
            content:'',
            pic:[]
        }
    },

   
    onLoad(options) {

    },
    submit(e){
    },
    uploadpic(){
        const that = this;
        wx.chooseMedia({
            count: 1,
            sizeType: ['original', 'compressed'],
            sourceType: ['album', 'camera'],
            mediaType: ['image'],
            maxDuration: 30,
            camera: 'back',
            success: function (res) {
                var tempFilePath = res.tempFiles[0].tempFilePath;
                wx.uploadFile({
                    url: 'http://' + ipconfig + ':8080/tool/upload',
                    filePath: tempFilePath,
                    name: 'file',
                    header: {
                        'Authorization': wx.getStorageSync('token')
                    },
                    success: function (res) {
                        const data1 = JSON.parse(res.data)
                        let array = that.data.feedback.pic;
                        array.push('http://ruuqwf8y6.hn-bkt.clouddn.com/'+data1.data)
                        that.setData({
                            'feedback.pic':array
                        })
                    },
                    fail: function (err) {
                        console.log(err);
                    }
                });

            },
            fail: function (err) {
                console.log(err);
            }
        })
    },

      formSubmit(e) {
        this.setData({
            "feedback.content":e.detail.value.content,
            "feedback.type":"user"
        })
		http.post("/feedback/addFeedBack",this.data.feedback,res=>{
            console.log(res);
            wx.navigateBack();
        })
      },
    
      formReset(e) {
        console.log('form发生了reset事件，携带数据为：', e.detail.value)
        wx.navigateBack()
      }
})